<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="com.example.demo2.DBUtil" %>
<%@ page import="java.util.HashMap" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Insert title here</title>
		<link rel="stylesheet" type="text/css" href="css/rest.css"/>
		<link rel="stylesheet" href="css/bootstrap.css">

		<style type="text/css">
			body{width: 100%;height: 100%;}
			*{margin: 0;padding: 0;}
				.bjt{background:radial-gradient(#6f4351,#40325b);width: 100%;height: 120px;}
				.huixiang{width: 200px;height: 80px;position: absolute;left: 0px;top: 10px;}
				.ziti{font-size: 25px;font-style: italic;font-family: 宋体;color:#91b5ff ;font-weight: 600;position: absolute;left:180px;top: 44px;}
				li{float: left;font-size: 22px;padding: 10px;margin-left: 60px;color: aqua;}
				.liebiao{position: absolute;left: 300px;top: 35px;}
				.zixuankuang{font-size: 12px;color: gray;width: 210px;height:38px;position: absolute;left: 1100px;top: 38px;border-radius: 50px;}
				.sousuo{width: 40px;height: 38px;position: absolute;left: 1274px;top: 40px;border-radius: 50px;background-color: dimgray;}
				.si{background-color: black;height: 300px;position: relative; margin-top: 30px}
				.c1{font-size: 18px;font-weight: 300;color: white;position: absolute;left: 450px;top: 50px;}
				.c1-1{color: red;}
				.c2{font-size: 18px;font-weight: 300;position: absolute;left: 520px;top:80px;color: white;}
				.c3{font-size: 18px;font-weight: 300;color: white;position: absolute;left: 600px;top:120px;}
				.c4{height: 40px;width: 130px;position: absolute;left: 580px;top:180px;}
				.c5{height: 40px;width: 130px;position: absolute;left: 740px;top:180px;}
				.c6{height: 40px;width: 130px;position: absolute;left: 900px;top:180px;}
					li>a{color: white;}
				.java-beijing-1{width: 100%;height: 225px;position: absolute;}
				.java-beijing-2{width: 172px;height: 245px;top: -10px;position: absolute;left: 350px;}
				.mztkn{color: white;position: absolute;left: 600px;}
				.mztkn-1{font-size: 25px;}
				.mztkn-2{font-size: 18px;padding-top: 10px;}
				.mztkn-3{font-size: 15px;padding-top: 10px;}
				.pf{color: white;position: absolute;left: 600px;top:340px;}
				.fenshu{color:yellow;position: absolute;left: 18px;top:26px;font-size: 20px;}
				.piaofang{color: white;position: absolute;left: 700px;top:340px;}
				.piaofang-1{color: yellow;position: absolute;left: 700px;top:367px;font-size: 20px;}
						.denglu>a{color: white;}
				.z1-1>img{height: 300px;}
				.x1{margin-top: 50px;margin-left: 310px;font-size: 24px;}
				.z1{width: 1600px;height: 350px;background-color: gainsboro;margin-left: 150px;margin-top: 200px;padding-top: 25px;}
				.z1-1{height: 300px;width: 218px;}
				.v1{font-size: 30px;height: 40px;position:absolute;top: 960px;left: 200px;text-align: center;line-height: 40px;}
				.v1-1{font-size: 15px;height: 40px;width: 600px;position:absolute;top:1000px;left: 100px;text-align: center;line-height: 40px;}
				.v2{width: 1500px;margin-top: 240px;margin-left: 200px;}
				.v2-1{font-size: 20px;}
				.v2-2{font-size: 18px;margin-top: 45px;}
				.active{border: solid 5px red;}
		</style>
	</head>
	<body>
		<div class="bjt">
			<img src="img/R-C.png" class="huixiang">
			<div class="ziti">悦享汇电影</div>
			<div class="liebiao">
				<ul>
				<li><a href="shouye.jsp">首页</a></li>
				<li><a href="dianying.jsp">电影</a></li>
				<li><a href="yingyuan.jsp">影院</a></li>
				<li><a href="bangdan.jsp">榜单</a></li>
				<li><a href="redian.jsp">热点</a></li>
				<li><a href="shangcheng.jsp">商城</a></li>
			</ul>
			</div>
			<%@include file="sousuo.jsp"%>
			<%@include file="dl.jsp"%>
		</div>
				<%
						String m_id = request.getParameter("id");
						String y_id = request.getParameter("y_id");
						String ff_id = request.getParameter("f_id");
						String gp = request.getParameter("gp");
						Connection cn = null;
						PreparedStatement ps = null;
						ResultSet rs = null;
						String sql = "";
						cn = DBUtil.getConnection();
						sql = "select * from cinema WHERE id=" + y_id;
						ps = cn.prepareStatement(sql);
						rs = ps.executeQuery();
						String name ="";
						String name2 ="";
						String dizhi ="";
						String phone ="";
						String img ="";
						String fuw ="";
						String time ="";
						String leix ="";
						String diqandshic ="";
						String zhuyan ="";
//					System.out.println(u_id);
//					System.out.println(request.getContextPath());
					if (gp != null){
							int n=0;
							sql = "insert into dyp_dd(g_id,f_id,u_id,y_id) values(?,?,?,?)";
							ps = cn.prepareStatement(sql);

							ps.setObject(1, m_id);
							ps.setObject(2, ff_id);
							ps.setObject(3, u_id);
							ps.setObject(4, y_id);
							n= ps.executeUpdate();
							response.sendRedirect("xuanzuo.jsp?id=" + m_id +"&y_id=" + y_id);
					}
						while (rs.next()) {
							name = rs.getString("name");
							dizhi = rs.getString("dizhi");
							fuw = rs.getString("fuw");
							phone = rs.getString("phone");
						}
						sql = "select * from goods WHERE id=" + m_id;
						ps = cn.prepareStatement(sql);
						rs = ps.executeQuery();
						while (rs.next()) {
							img = rs.getString("img");
							name2 = rs.getString("name");
							diqandshic = rs.getString("diqandshic");
							leix = rs.getString("leix");
							zhuyan = rs.getString("zhuyan");
						}
					%>
			<div style="position: relative;margin-top: 50px;height: 80px;">
				<img src="img/1237.jpg" class="java-beijing-1" >
				<%if (m_id !=null){%>
				<img src="<%=img%>" class="java-beijing-2">
				<%}%>
				<div class="mztkn">

					<div class="mztkn-1">	<%=name%> <br></div>
					<div class="mztkn-2"><%=dizhi%><br></div>
					<div class="mztkn-3">电话：<%=phone%><br></div>
					<div class="mztkn-4">影院服务                      ————————————————<br></div>
					<div class="mztkn-5"><span class="tag ">&nbsp;&nbsp;&nbsp;改签&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
						<span class="mztkn-5-1" title="未取票用户放映前0分钟可改签">&nbsp;未取票用户放映前0分钟可改签</span></div>
					<div class="mztkn-6"> <span class="tag ">&nbsp;3D眼镜&nbsp;&nbsp;&nbsp;</span>
						<span class="mztkn-6-1" title="0">&nbsp;&nbsp;0</span></div>
					<div class="mztkn-7"> <span class="tag ">&nbsp;儿童优惠&nbsp;</span>
						<span class="mztkn-7-1" title="0">&nbsp;Ｖ+影城儿童观影政策： 1. 如您在V+影城携带1.3米（含）以下儿童观影.......</span></div>
					<div class="mztkn-8"> <span class="tag ">&nbsp;情侣座&nbsp;&nbsp;&nbsp;&nbsp;</span>
						<span class="mztkn-8-1" title="0">&nbsp;情侣厅和VIP儿童也需购票">情侣厅和VIP儿童也需购票</span></div>

				</div>

			</div>

				
					<div class="z1">
						<ul>
							<%
								int count = 0;
								PreparedStatement num = null;
								num = cn.prepareStatement("select count(*) as totalCount from goods where 1=1");

								rs = num.executeQuery();
								if(rs.next()) {
									count=rs.getInt("totalCount");
								}
								java.util.Random random= new  java.util.Random();
								int  result=random.nextInt(count-5);
								sql = "select * from goods limit "+result+","+5;
								ps = cn.prepareStatement(sql);
								rs = ps.executeQuery();
								String m_id2 = "";
								while (rs.next()) {
									img = rs.getString("img");
									m_id2 = rs.getString("id");
							%>
							<li>
								<a href="xuanzuo.jsp?id=<%=m_id2%>&y_id=<%=y_id%>">
									<div class="z1-1 <%if (m_id2.equals(m_id)){%>active<%}%>">
										<img src="<%=img%>"/>
									</div>
								</a>
							</li>
							<%
								}
							%>
							
						</ul>

					</div>

				<%if (m_id !=null){%>
					<div class="v1"><%=name2%></div>
					<div class="v1-1">时长 : <%=diqandshic%>&nbsp;&nbsp;&nbsp;主演 : <%=zhuyan%></div>
					<div class="v2">
						<%
							num = cn.prepareStatement("select count(*) as totalCount from fyt where c_id = "+y_id + " and g_id=" + m_id);

							rs = num.executeQuery();
							if(rs.next()) {
								count=rs.getInt("totalCount");
							}
							if (count != 0){
						%>
						<table style="width: 100%">
							<tr style="text-align: center">
								<th>放映时间</th>
								<th>语言版本</th>
								<th>放映厅</th>
								<th>售价（元）</th>
								<th>选座购票</th>
							</tr>
							<%
								sql = "select * from fyt where c_id = "+y_id + " and g_id=" + m_id;
								ps = cn.prepareStatement(sql);
								rs = ps.executeQuery();
								String f_id;
								String f_time;
								String o_time;
								String language;
								String f_name;
								String f_qian;

									while (rs.next()) {
										f_id = rs.getString("id");
										f_time =rs.getString("time").substring(0,5);
										o_time =rs.getString("o_time").substring(0,5);
										language =rs.getString("language");
										f_name =rs.getString("name");
										f_qian =rs.getString("qian");
								%>
								<tr style="height: 100px;text-align: center;">
									<td><%=f_time%><br><%=o_time%>散场</td>
									<td><%=language%></td>
									<td><%=f_name%></td>
									<td>¥<%=f_qian%></td>
									<td>
										<button type="button" class="btn btn-primary btn-sm"
												data-toggle="modal" data-target="#exampleModal"
												<%if (condition ==null){
												%>
												disabled
												<%
												}
												%>
												style="margin-bottom: 20px;margin-right: 5px">
											<%
												if (condition==null){
											%>
												请登录
											<%
												} else {
											%>
												选座购票
											<%
												}
											%>
										</button>
									</td>
								</tr>
							<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
								<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
									<div class="modal-content">
										<div class="modal-header">
											<h5 class="modal-title" id="exampleModalLabel">扫码付款</h5>
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
												<span aria-hidden="true">&times;</span>
											</button>
										</div>


										<div class="modal-body">
											<div class="form-group">
												<img src="img/qrfk.png">
											</div>

										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
											<a href="xuanzuo.jsp?gp=t&id=<%=m_id%>&y_id=<%=y_id%>&f_id=<%=f_id%> " type="submit" class="btn btn-primary">确认</a>
										</div>
									</div>
								</div>
							</div>

							<%
									}
								}else{
										out.println("<h2 style=\"text-align: center;\">暂无排座!</h2>");
								}

							%>
						</table>


					</div>
				<%}%>


		<div class="si">
			<div class="c1">关于悦享汇：<span class="c1-1">关于我们	| 管理团队 | 投资者关系 |</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;友情链接：<span class="c1-1">美团网 | 美团下载 | 欢喜首映 |</span></div>
			<div class="c2">QQ邮箱：2112633811.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;客服电话：152425125</div>
			<div class="c3">悦享汇用户服务协议 |			悦享汇平台交易规则总则 | 			隐私政策 |</div>
			<img src="img/C9.png"class="c4" >
			<img src="img/C8.png"class="c5" >
			<img src="img/C7.png"class="c6" >

		</div>



	</body>
	<script src="js/jQuery.js"></script>
	<script src="js/bootstrap.js"></script>
</html>
